Skip to content
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.

feat: drupal 10 compatibility update #135

Merged
merged 9 commits into from
Nov 16, 2023

Conversation

vincent-gao
Copy link
Collaborator

@vincent-gao vincent-gao commented Jun 29, 2023

JIRA

https://digital-vic.atlassian.net/browse/SRM-942

Changes

Drupal 10 compatibility changes.

@vincent-gao vincent-gao force-pushed the feature/SRM-942-drupal-10 branch from 1557be4 to f992a96 Compare June 30, 2023 00:57
@vincent-gao vincent-gao force-pushed the feature/SRM-942-drupal-10 branch from f992a96 to e8fb662 Compare June 30, 2023 02:58
@vincent-gao vincent-gao changed the title fix: building issue feat: drupal 10 compatibility update Jun 30, 2023
@vincent-gao vincent-gao marked this pull request as ready for review June 30, 2023 02:58
@@ -658,6 +658,7 @@ function tide_site_taxonomy_term_delete($term) {
$path_storage = \Drupal::entityTypeManager()->getStorage('path_alias');
$site_prefix = $helper->getSitePathPrefix($term);
$path_ids = \Drupal::entityQuery('path_alias')
->accessCheck(TRUE)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is regarding this change - https://www.drupal.org/node/3201242

@@ -690,6 +691,7 @@ function tide_site_node_update($node) {
foreach ($unassigned_sites as $unassigned_site_id) {
$site_prefix = $helper->getSitePathPrefix($unassigned_site_id);
$path_ids = \Drupal::entityQuery('path_alias')
->accessCheck(TRUE)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is regarding this change - https://www.drupal.org/node/3201242

*
* @todo Extract into a service.
*/
function tide_site_field_widget_form_alter(&$element, FormStateInterface $form_state, $context) {
function tide_site_field_widget_single_element_form_alter(&$element, FormStateInterface $form_state, $context) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

deprecated in 9.5 and removed in d10, so had to update this to work - https://www.drupal.org/node/3180429

@@ -11,14 +11,14 @@
use Drupal\jsonapi_extras\ResourceType\ConfigurableResourceType;
use Drupal\tide_site\TideSiteFields;
use Drupal\tide_site\TideSiteHelper;
use Symfony\Cmf\Component\Routing\RouteObjectInterface;
use Drupal\Core\Routing\RouteObjectInterface;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change related to this - https://www.drupal.org/node/3151009

use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\Event\ResponseEvent;
use Symfony\Component\HttpKernel\Event\RequestEvent;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updating Symfony response and request events to new classes

* The event.
*
* @see \Symfony\Component\HttpKernel\HttpKernel::handleRaw()
* @see \Drupal\jsonapi\Controller\RequestHandler::handle()
*/
public function onRequestAddSiteFilter(GetResponseEvent $event) {
public function onRequestAddSiteFilter(RequestEvent $event) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updating Symfony response and request events to new classes

$response = $event->getResponse();
if (!$response instanceof CacheableResponseInterface) {
return;
}

$site_id = $event->getRequest()->query->get('site');
$site_id = $event->getRequest()->query->all()['site'] ?? [];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In symfony 6, the InputBag::get(), no longer accepts arrays as default values

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I used to use query->get so much in Symfony work, I have no idea why the moved it towards the fetch all as an array and get the element (probably a PHP 8 thing truth be told)

@@ -246,22 +246,22 @@ public function onResponseAddSiteFilterCacheContext(FilterResponseEvent $event)
* The Resource type.
*/
protected function setSiteFilterToJsonApi(Request $request, array $site_filter, ConfigurableResourceType $resource_type) {
$filter = $request->query->get('filter', []);
$filter = $request->query->all()['filter'] ?? [];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In symfony 6, the InputBag::get(), no longer accepts arrays as default values

@@ -69,7 +69,7 @@ public static function create(ContainerInterface $container, array $configuratio
*/
public function getUrl(EntityInterface $entity) {
/** @var \Drupal\Core\GeneratedUrl $url */
$url = parent::getUrl($entity);
$url = parent::getUrl($entity)->toString(TRUE);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this has been changed to tackle this issue - https://digital-vic.atlassian.net/browse/SRM-1167
Recently linkit module did a new release and it changed the getUrl function return from return $entity->toUrl('canonical')->toString(TRUE); to return $entity->toUrl('canonical');
It causes issues for our custom plugin as it returns the url object instead of string. So to fix that, converting it here in the custom plugin.

Copy link
Contributor

@anthony-malkoun anthony-malkoun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I appreciate the links to issues that needing fixing! This is a great example of leading the reviewer through difficult to understand/grok changes.

"drupal/key_value_field": "^1.3"
},
"suggest": {
"dpc-sdp/tide_api:^3.0.0": "Allows to use Drupal in headless mode"
"dpc-sdp/tide_api:^4.0.0": "Allows to use Drupal in headless mode"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Breaking change, good job!

@MdNadimHossain MdNadimHossain merged commit 23c1939 into develop Nov 16, 2023
@MdNadimHossain MdNadimHossain deleted the feature/SRM-942-drupal-10 branch November 16, 2023 23:04
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants